using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Input.Touch;
using Microsoft.Xna.Framework.Media;
namespace TurbaconPhone
{
    public abstract class GameObject : GameComponent
    {
        public abstract Vector2 Pos { get; set; }
        public abstract Vector2 Vel { get; set; }
        public abstract float Angle { get; set; }
        public abstract float AngVel { get; set; }
        public abstract float Scale { get; set; }
        public Color Color { get; set; }
        public bool HasTrail { get; set; }
        public Color TrailColor { get; set; }
        public bool bDead
        {
            get;
            private set;
        }

        public bool OnFire = false; 

        public Texture2D TrailTexture;
        public Texture2D Texture;
        public GameObject(string textureName)
            : base(Program.Game)
        {
            //Program.Game.AddObject(this);
            GameplayState.gObjects.Add(this);
            if (textureName != null)
            {
                Texture = TurBacon.Content.GetTexture(textureName);
            }
            else
            {
                Texture = null;
            }
            HasTrail = false;
            TrailColor = Color.White;
        }
        public GameObject(Texture2D texture)
            : base(Program.Game)
        {
            //Program.Game.AddObject(this);
            GameplayState.gObjects.Add(this);
            Texture = texture;
            HasTrail = false;
        }

        public virtual void Draw(SpriteBatch spriteBatch)
        {
            if(Texture!=null)
                spriteBatch.Draw(Texture, Pos, null, Color, Angle, new Vector2(Texture.Width / 2, Texture.Height / 2), Scale, SpriteEffects.None, 0);
        }

        public virtual void DrawTrail(SpriteBatch spriteBatch)
        {
            if (TrailTexture != null)
                spriteBatch.Draw(TrailTexture, Pos, null, TrailColor, Angle, new Vector2(Texture.Width / 2, Texture.Height / 2), Scale, SpriteEffects.None, 0);
            else Draw(spriteBatch);
        }

        public virtual void Die()
        {
            if (!bDead)
            {
               // Program.Game.RemoveObject(this);
                GameplayState.gObjects.Remove(this);
                bDead = true;
            }
        }
        public virtual void Destroy(){}
    }
}
